allow testing the end position
authorHavoc Pennington <hp@redhat.com>
Wed, 3 Oct 2001 20:49:10 +0000 (20:49 +0000)
committerHavoc Pennington <hp@src.gnome.org>
Wed, 3 Oct 2001 20:49:10 +0000 (20:49 +0000)
2001-10-03  Havoc Pennington  <hp@redhat.com>

* gtk/gtktextiter.c (test_log_attrs): allow testing the end
position

* gtk/gtktextbuffer.c (compute_log_attrs): update for pango
changes

* tests/testtextbuffer.c (logical_motion_tests): updates

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtktextbuffer.c
gtk/gtktextiter.c
tests/testtextbuffer.c

index ce42f2c37acb7f5d594510470a38d1f34239ea52..4e48578c54d6a40d995660638c79a4ac067759a5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2001-10-03  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (test_log_attrs): allow testing the end 
+       position
+
+       * gtk/gtktextbuffer.c (compute_log_attrs): update for pango
+       changes
+
+       * tests/testtextbuffer.c (logical_motion_tests): updates
+
 2001-10-03  jacob berkman  <jacob@ximian.com>
 
        * gtk/gtkwidget.c (gtk_widget_style_get_property): 
index ce42f2c37acb7f5d594510470a38d1f34239ea52..4e48578c54d6a40d995660638c79a4ac067759a5 100644 (file)
@@ -1,3 +1,13 @@
+2001-10-03  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (test_log_attrs): allow testing the end 
+       position
+
+       * gtk/gtktextbuffer.c (compute_log_attrs): update for pango
+       changes
+
+       * tests/testtextbuffer.c (logical_motion_tests): updates
+
 2001-10-03  jacob berkman  <jacob@ximian.com>
 
        * gtk/gtkwidget.c (gtk_widget_style_get_property): 
index ce42f2c37acb7f5d594510470a38d1f34239ea52..4e48578c54d6a40d995660638c79a4ac067759a5 100644 (file)
@@ -1,3 +1,13 @@
+2001-10-03  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (test_log_attrs): allow testing the end 
+       position
+
+       * gtk/gtktextbuffer.c (compute_log_attrs): update for pango
+       changes
+
+       * tests/testtextbuffer.c (logical_motion_tests): updates
+
 2001-10-03  jacob berkman  <jacob@ximian.com>
 
        * gtk/gtkwidget.c (gtk_widget_style_get_property): 
index ce42f2c37acb7f5d594510470a38d1f34239ea52..4e48578c54d6a40d995660638c79a4ac067759a5 100644 (file)
@@ -1,3 +1,13 @@
+2001-10-03  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (test_log_attrs): allow testing the end 
+       position
+
+       * gtk/gtktextbuffer.c (compute_log_attrs): update for pango
+       changes
+
+       * tests/testtextbuffer.c (logical_motion_tests): updates
+
 2001-10-03  jacob berkman  <jacob@ximian.com>
 
        * gtk/gtkwidget.c (gtk_widget_style_get_property): 
index ce42f2c37acb7f5d594510470a38d1f34239ea52..4e48578c54d6a40d995660638c79a4ac067759a5 100644 (file)
@@ -1,3 +1,13 @@
+2001-10-03  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (test_log_attrs): allow testing the end 
+       position
+
+       * gtk/gtktextbuffer.c (compute_log_attrs): update for pango
+       changes
+
+       * tests/testtextbuffer.c (logical_motion_tests): updates
+
 2001-10-03  jacob berkman  <jacob@ximian.com>
 
        * gtk/gtkwidget.c (gtk_widget_style_get_property): 
index ce42f2c37acb7f5d594510470a38d1f34239ea52..4e48578c54d6a40d995660638c79a4ac067759a5 100644 (file)
@@ -1,3 +1,13 @@
+2001-10-03  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (test_log_attrs): allow testing the end 
+       position
+
+       * gtk/gtktextbuffer.c (compute_log_attrs): update for pango
+       changes
+
+       * tests/testtextbuffer.c (logical_motion_tests): updates
+
 2001-10-03  jacob berkman  <jacob@ximian.com>
 
        * gtk/gtkwidget.c (gtk_widget_style_get_property): 
index ce42f2c37acb7f5d594510470a38d1f34239ea52..4e48578c54d6a40d995660638c79a4ac067759a5 100644 (file)
@@ -1,3 +1,13 @@
+2001-10-03  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (test_log_attrs): allow testing the end 
+       position
+
+       * gtk/gtktextbuffer.c (compute_log_attrs): update for pango
+       changes
+
+       * tests/testtextbuffer.c (logical_motion_tests): updates
+
 2001-10-03  jacob berkman  <jacob@ximian.com>
 
        * gtk/gtkwidget.c (gtk_widget_style_get_property): 
index 12d8eeb27082a8ba43f91918c0577a4693cff31d..ec2ded7e49f83228b201607478cd724b5ebddd06 100644 (file)
@@ -3419,11 +3419,15 @@ compute_log_attrs (const GtkTextIter *iter,
   if (char_lenp)
     *char_lenp = char_len;
   
-  attrs = g_new (PangoLogAttr, char_len);
-  
+  attrs = g_new (PangoLogAttr, char_len + 1);
+
+  /* FIXME we need to follow PangoLayout and allow different language
+   * tags within the paragraph
+   */
   pango_get_log_attrs (paragraph, byte_len, -1,
                       gtk_text_iter_get_language (&start),
-                       attrs);
+                       attrs,
+                       char_len + 1);
   
   g_free (paragraph);
 
index a3245437c9b00c178d83800b6006368c442c66af..62cbde55b523008cf9af77d39204b7c6037bb152 100644 (file)
@@ -2852,10 +2852,13 @@ test_log_attrs (const GtkTextIter *iter,
   offset = gtk_text_iter_get_line_offset (iter);
 
   /* char_len may be 0 and attrs will be NULL if so, if
-   * iter is the end iter and the last line is empty
+   * iter is the end iter and the last line is empty.
+   * 
+   * offset may be equal to char_len, since attrs contains an entry
+   * for one past the end
    */
   
-  if (offset < char_len)
+  if (offset <= char_len)
     result = (* func) (attrs, offset, 0, char_len);
 
   return result;
index 3c6e6f3db6d18d9263fdd4ca22266389f46f8f78..175deb9857f97547a9f4896caaad5b1e1de2b22a 100644 (file)
@@ -957,6 +957,9 @@ logical_motion_tests (void)
 
   if (!gtk_text_iter_is_end (&iter))
     g_error ("Expected to stop at the end iterator\n");
+
+  if (!gtk_text_iter_is_cursor_position (&iter))
+    g_error ("Should be a cursor position before the end iterator");
   
   if (i != expected_steps)
     g_error ("Expected %d steps, there were actually %d\n", expected_steps, i);
@@ -1016,6 +1019,11 @@ logical_motion_tests (void)
                    pos, expected[i]);
         }
 
+      if (i != 0 &&
+          !gtk_text_iter_is_end (&iter) &&
+          !gtk_text_iter_ends_sentence (&iter))
+        g_error ("Iterator at %d should end a sentence", pos);
+      
       ++i;
     }
   while (gtk_text_iter_forward_sentence_end (&iter));
@@ -1054,6 +1062,11 @@ logical_motion_tests (void)
                    pos, expected[i]);
         }
 
+      if (pos != 0 &&
+          !gtk_text_iter_is_end (&iter) &&
+          !gtk_text_iter_starts_sentence (&iter))
+        g_error ("Iterator at %d should start a sentence", pos);
+      
       ++i;
     }
   while (gtk_text_iter_backward_sentence_start (&iter));